{% set RecentLiveCourses = data('RecentLiveCourses',{ 'count':4}) %}
{% if RecentLiveCourses %}
  <section class="live-course-section {{config.background|default("")}}">
    <div class="container">
      <div class="text-line gray">
        <h5><span>{{ config.title|default(config.defaultTitle) }}</span><div class="line"></div></h5>
        <div class="subtitle">{{ config.subTitle|default(config.defaultSubTitle) }}</div>
      </div>
      <div class="course-list"> 
        <div class="row"> 
          {% for course in RecentLiveCourses %} 
            <div class="col-lg-3 col-md-4 col-xs-6">
              {% include 'TopxiaWebBundle:Course:Widget/course-grid.html.twig' with {course:course} %} 

              {% set lesson = course['lesson']|default(null) %}
              {% if lesson and "now"|date("U") >= lesson.startTime and "now"|date("U") <= lesson.endTime %}
                <div class="course-date visible-lg">
                  <div class="btn-circle btn-live  btn-circle-md">
                    <i class="es-icon es-icon-videocam"></i>
                  </div>
                  <div class="date">
                    {{'正在直播'|trans}}
                  </div>
                </div>
              {% else %}
                <div class="course-date visible-lg">
                  <div class="btn-circle btn-circle-md">
                    <i class="es-icon es-icon-videocam"></i>
                  </div>
                  <div class="date">
                    {{ lesson.startTime|date('n月j日 H:i') }}
                  </div>
                </div>
              {% endif %}

            </div>
          {% endfor %}

          {% set emptyCourseNum = 4 - RecentLiveCourses|length %}
          {% if emptyCourseNum > 0 %}
            {% for i in range(1, emptyCourseNum) %}
              <div class="col-lg-3 col-md-4 col-sm-6 visible-lg">
                <div class="course-item course-default">
                  <i class="es-icon es-icon-videocam"></i>
                  <br>
                  {{'敬请期待'|trans}}
                </div>
                <div class="course-date">
                  <div class="btn-circle btn-circle-md">
                    <i class="es-icon es-icon-accesstime"></i>
                  </div>
                </div>
              </div>
            {% endfor %}
          {% endif %}
        </div>
      </div>
      <div class="section-more-btn">
        <a href="{{ path('live_course_explore') }}" class="btn btn-default btn-lg">
          {{'更多直播'|trans}} <i class="mrs-o es-icon es-icon-chevronright"></i>
        </a>
      </div>
    </div>
  </section>
{% endif %}
